#include  <cstdio>
#include  <ctype.h>

int main(int argc, char *argv[])
{
	char s[26];
	int n = 26,i = 0;
	while(n--)
		scanf("%c",&s[i++]);
	getchar();
	char c;
	bool up;
	while( (c = getchar()) != EOF )
	{
		up = false;
		if(c == ' ' )
		{
			putchar(' ');
			continue;
		}
		if(c == '\n')
		{
			printf("\n");
			break;
		}
		
		if(isupper(c))
		{
			c = tolower(c);
			up = true;
		}
		if(up)
			putchar(toupper(s[c-'a']));
		else
			putchar(s[c-'a']);
	}
}
